How to loop code until it works in Python

welcome to shbcf.ru